//#include <vfork.h>
#include <stdio.h>
#include <stdlib.h>
#include <sys/types.h>
#include <unistd.h>

int glob = 6; /* external variable in initialized data */

int main(void)
{
  int var;  /* automatic variable on the stack */
  pid_t pid;

  var = 88;
  printf("before vfork\n"); /* we don't flush stdio */

  if ((pid == vfork()) < 0)
    err_sys("vfork error");
  else if (pid == 0) {
    glob++; /* modify parent's variables */
    var++;
    _exit(0); /* child terminates */
  }

  /* parent */
  printf("pdi = %d, glob = %d, var = %d\n", getpid(), glob, var);
  exit(0);
}
